home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / fortran / toolpack.000 / toolpack / toolpack1.2 / f77 next >
Encoding:
Text File  |  1993-10-23  |  3.1 KB  |  173 lines

  1. #!/bin/sh
  2. PATH=/bin:/usr/bin
  3. # f77-style shell script to compile and load fortran, C, and assembly codes
  4. # hacked to use -O6
  5.  
  6. #    usage:    f77 [-g] [-O] [-o absfile] [-c] files [-l library]
  7.  
  8. #        -o objfile    Override default executable name a.out.
  9.  
  10. #        -c        Do not call linker, leave relocatables in *.o.
  11.  
  12. #        -C        Check that subscripts are in bounds.
  13.  
  14. #        -S        leave assembler output on file.s
  15.  
  16. #        -l library    (passed to ld).
  17.  
  18. #        -u        complain about undeclared variables
  19.  
  20. #        -w        omit all warning messages
  21.  
  22. #        -w66        omit Fortran 66 compatibility warning messages
  23.  
  24. #        files        FORTRAN source files ending in .f .
  25. #                C source files ending in .c .
  26. #                Assembly language files ending in .s .
  27.  
  28. #        -D def        passed to C compiler (for .c files)
  29.  
  30. #        -I includepath    passed to C compiler (for .c files)
  31.  
  32. #        -Ntnnn        allow nnn entries in table t
  33.  
  34. s=/tmp/stderr_$$
  35. t=/tmp/f77_$$.o
  36. CC=${CC_f2c:-'/usr/bin/cc'}
  37. F2C=${F2C:-/usr/bin/f2c}
  38. F2CFLAGS=${F2CFLAGS:='-ARw8 -Nn802'}
  39. rc=0
  40. trap "rm -f $s $t; exit \$rc" 0
  41. lib=/lib/num/lib.lo
  42. OUTF=a.out
  43. cOPT=1
  44. set -- `getopt cCD:gI:N:Oo:Suw6 "$@"`
  45. case $? in 0);; *) exit 1;; esac
  46. CCFLAGS=
  47. while
  48.     test X"$1" != X--
  49. do
  50.     case "$1"
  51.     in
  52.     -C)    F2CFLAGS="$F2CFLAGS -C"
  53.         shift;;
  54.  
  55.     -c)    cOPT=0
  56.         shift
  57.         ;;
  58.  
  59.     -D)    CCFLAGS="$CCFLAGS -D$2"
  60.         shift 2
  61.         ;;
  62.  
  63.     -g)    CFLAGS="$CFLAGS -g"
  64.         CCFLAGS="$CCFLAGS -g"
  65.         F2CFLAGS="$F2CFLAGS -g"
  66.         shift;;
  67.  
  68.     -I)    CCFLAGS="$CCFLAGS -I$2"
  69.         shift 2
  70.         ;;
  71.  
  72.     -o)    OUTF=$2
  73.         shift 2
  74.         ;;
  75.  
  76.     -O)    case $2 in -1) O=-O1;; -2) O=-O2;; -3) O=-O3;; -6) O=-O6;; *) O=-O;; esac
  77.         case $O in -O);; *) shift;; esac
  78.         # lcc ignores -O...
  79.         shift
  80.         ;;
  81.  
  82.     -u)    F2CFLAGS="$F2CFLAGS -u"
  83.         shift
  84.         ;;
  85.  
  86.     -w)    F2CFLAGS="$F2CFLAGS -w"
  87.         case $2 in -6) F2CFLAGS="$F2CFLAGS"66; shift
  88.             case $2 in -6) shift;; esac;; esac
  89.         shift
  90.         ;;
  91.  
  92.     -N)    F2CFLAGS="$F2CFLAGS $1""$2"
  93.         shift 2
  94.         ;;
  95.  
  96.     -S)    CFLAGS="$CFLAGS -S"
  97.         cOPT=0
  98.         shift
  99.         ;;
  100.  
  101.     *)
  102.         echo "invalid parameter $1" 1>&2
  103.         shift
  104.         ;;
  105.     esac
  106. done
  107. shift
  108. while
  109.     test -n "$1"
  110. do
  111.     case "$1"
  112.     in
  113.     *.[fF])
  114.         case "$1" in *.f) f=".f";; *.F) f=".F";; esac
  115.         b=`basename $1 $f`
  116.         $F2C $F2CFLAGS $1
  117.         case $? in 0);; *) exit;; esac
  118.                 $CC -c $CFLAGS $b.c 2>$s
  119.         rc=$?
  120.         sed '/parameter .* is not referenced/d;/warning: too many parameters/d' $s 1>&2
  121.         case $rc in 0);; *) exit;; esac
  122.         OFILES="$OFILES $b.o"
  123.         rm $b.c
  124.         case $cOPT in 1) cOPT=2;; esac
  125.         shift
  126.         ;;
  127.     *.s)
  128.         echo $1: 1>&2
  129.         OFILE=`basename $1 .s`.o
  130.         ${AS:-/usr/bin/as} -o $OFILE $AFLAGS $1
  131.         case $? in 0);; *) exit;; esac
  132.         OFILES="$OFILES $OFILE"
  133.         case $cOPT in 1) cOPT=2;; esac
  134.         shift
  135.         ;;
  136.     *.c)
  137.         echo $1: 1>&2
  138.         OFILE=`basename $1 .c`.o
  139.                 $CC -c $CFLAGS $CCFLAGS $1
  140.         rc=$?; case $rc in 0);; *) exit;; esac
  141.         OFILES="$OFILES $OFILE"
  142.         case $cOPT in 1) cOPT=2;; esac
  143.         shift
  144.         ;;
  145.     *.o)
  146.         OFILES="$OFILES $1"
  147.         case $cOPT in 1) cOPT=2;; esac
  148.         shift
  149.         ;;
  150.     -l)
  151.         OFILES="$OFILES -l$2"
  152.         shift 2
  153.         case $cOPT in 1) cOPT=2;; esac
  154.         ;;
  155.     -l*)
  156.         OFILES="$OFILES $1"
  157.         shift
  158.         case $cOPT in 1) cOPT=2;; esac
  159.         ;;
  160.     -o)
  161.         OUTF=$2; shift 2;;
  162.     *)
  163.         OFILES="$OFILES $1"
  164.         shift
  165.         case $cOPT in 1) cOPT=2;; esac
  166.         ;;
  167.     esac
  168. done
  169.  
  170. case $cOPT in 2) $CC -o $OUTF -u MAIN__ $OFILES -lf2c -lm;; esac
  171. rc=$?
  172. exit $rc
  173.